import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:proj_shop/pages/index_page.dart';
import 'package:proj_shop/util/navigator_util.dart';
import 'package:proj_shop/widgets/grid_list.dart';
import 'package:server_manager/author/http_author.dart';
import 'package:flutter_page_indicator/flutter_page_indicator.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  HttpAuthor httpAuthor = HttpAuthor();
  String desc = "empty";

  List<String> images = [
    "images/bg0.jpeg",
    "images/bg1.jpeg",
    "images/bg2.jpeg",
  ];

  List<Map> gridList = [
    {'pic': "images/Hotline.png", "name": "Hotline"},
    {'pic': "images/Invitation.png", "name": "Invitation"},
    {'pic': "images/Monthlycard.png", "name": "Monthlycard"},
    {'pic': "images/Opendoor.png", "name": "Opendoor"},
    {'pic': "images/Park.png", "name": "Park"},
    {'pic': "images/Pay.png", "name": "Pay"},
    {'pic': "images/Release.png", "name": "Release"},
    {'pic': "images/activity.png", "name": "activity"},
    {'pic': "images/top.png", "name": "top"},
    {'pic': "images/top.png", "name": "top"},
  ];

  void localShowDatePicker(BuildContext context) async {
    var result = showDatePicker(
      context: context,
      firstDate: DateTime(2020),
      lastDate: DateTime(2021),
      initialDate: DateTime.now(),
    );
    print('$result');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          /*httpAuthor.profile(serverCallBack: (String code, message, data) {
            print("code: $code");
            print("message: $message");
            print("data: $data,${httpAuthor.profileEntity.userId}");
            setState(() {
              desc = httpAuthor.profileEntity.desc;
            });
          });
          */
          NavigatorUtil.push(context, IndexPage());
        },
        child: Text("约课"),
      ),
      appBar: AppBar(title: Text("百姓生活+")),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Container(
              height: 150,
              child: Swiper(
                itemCount: images.length,
                itemBuilder: (_, int index) {
                  return Image.asset(images[index], fit: BoxFit.fill);
                },
                autoplay: true,
                indicatorLayout: PageIndicatorLayout.COLOR,
                pagination: SwiperPagination(alignment: Alignment.bottomCenter),
              ),
            ),
            GridList(dataSource: gridList),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
            Text(
                'datadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadatadata'),
          ],
        ),
      ),
    );
  }
}
